/**
 * 替换字符串中所有匹配的内容
 * @param source 源字符串
 * @param search 要查找的字符串
 * @param replacement 替换的字符串
 * @returns 替换后的字符串
 */
export const replaceAll = (
	source: string, 
	search: string, 
	replacement: string
): string => {
	// 转义特殊字符，避免正则表达式错误
	const escapedSearch = search.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
	return source.replace(new RegExp(escapedSearch, 'gm'), replacement)
}
